package com.zuo.newktproject.hilt

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import kotlinx.coroutines.delay
import javax.inject.Inject

interface MyRepository {
    suspend fun fetchData(): String
    fun getLiveData(): LiveData<String>
}

class MyRepositoryImpl @Inject constructor() : MyRepository {
    private val _data = MutableLiveData<String>("Initial Data")

    override suspend fun fetchData(): String {
        // 模拟网络请求
        delay(1000)
        _data.postValue("Fetched Data New")
        return "new Fetched Data"
    }

    override fun getLiveData(): LiveData<String> = _data
}
